package day5;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author oldliu
 * @since 1.0
 */
public class Birthday {
    public static void main(String[] args) throws ParseException {
        String input = "9-13";
        Calendar c = Calendar.getInstance();
        c.set(Calendar.HOUR,0);
        c.set(Calendar.MINUTE,0);
        c.set(Calendar.SECOND,0);
        c.set(Calendar.MILLISECOND,0);
        Calendar birth = Calendar.getInstance();

        int year = c.get(Calendar.YEAR);
        input = year + "-" + input;//yyyy-MM-dd
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date date = df.parse(input);
        birth.setTime(date);
        System.out.println(birth.getTime());
        System.out.println(c.getTime());
        System.out.println(c.before(birth));
        if (!c.before(birth) && c.compareTo(birth)!=0)
            birth.add(Calendar.YEAR, 1);
        //birth-c

        int days = (int) Math.ceil ((birth.getTimeInMillis() - c.getTimeInMillis()) / 86400.0 / 1000);
        System.out.println(days);
    }
}
